<? include 'server_config.php'; 

if($_SESSION['user_idx'] == "")
{
	?>
	<script>
		location.href='login.php';
	</script>
	<?
	return;
}


?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
	<title>NextDoorDoctor : 넥스트도어닥터 - 약, 치료 - 나의 약, 치료 입력</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="Stylesheet" type="text/css" href="./css/nddCommon.css" />
	<script type="text/javascript" src="./js/jquery-1.6.2.min.js"></script>
	<script type="text/javascript" src="./js/auto_drug.js"></script>
	
</head>

 <body>
	<div id='wrapper'>
        <?
        include "top_menu.php";
        ?>
		
		<div id='left_bg'>
		</div>


		<div id='title'>
			<div id='title_margin_top'><span></span></div>
			<div style='width:195px;height:29px;float:left;'></div>
			<div style='width:41px;height:29px;float:left;'><img src="./img/top_icon_input.png"></div><div style='height:29px;float:left;margin-top:3px;'><span id='article_content' >사용하시는 약, 치료를 입력해주세요</span></div>
		</div>

		<?
		$current_file = basename(__FILE__);
		include 'side_menu_input.php';
		?>
					

		<div id='middle_bg'>
		</div>


<?
			$disease_idx=0;
?>		

		<div id='document_content' style="width:776px;float:left;">
			<div style='height:2px;width:100%;background:#cccccc;float:left;'><span><span></div>
			<div style='height:3px;width:100%;float:left;'><span><span></div>

			<div style="width:714px;background:#F2F2F2;float:left;border:1px solid #E9E9E9;padding:30px;">
				<div style="width:30px;height:30px;float:left;">1</div>
				<div style="width:600px;float:left;">
					<form action='ndd_cure_drug_add.php' method="post" enctype="multipart/form-data" id="frm_drug_add" target="iframe_temp">

					<input type='hidden' name='disease_idx' value='0'>
					<input type='hidden' name='category_idx' id='category_idx' value="">

					어떤 치료를 받으셨습니까?<br>
					<br>
					
					<script>
					
					function set_category(_category_idx)
					{
						if($('#category_idx').val()!="")
						{
							$("#category_"+$('#category_idx').val()).css({"background-color":"white"});
					
						}

						
						$('#category_idx').val(_category_idx);
						$("#category_"+_category_idx).css({"background-color":"#e6e6e6"});
					
					}
						
					</script>

					<div style='width:70px;height:30px;background:#e6e6e6;float:left;border:1px solid #e6e6e6;padding-top:5px;text-align:center;cursor:pointer;' id="category_1" onclick='set_category(1);'>
						약
						<script>
						set_category(1);
						</script>
					</div>
					<div style='width:70px;height:30px;background:#ffffff;float:left;border:1px solid #e6e6e6;padding-top:5px;text-align:center;cursor:pointer;' id="category_2" onclick='set_category(2);'>
						한약, 보약
					</div>		
					<div style='width:70px;height:30px;background:#ffffff;float:left;border:1px solid #e6e6e6;padding-top:5px;text-align:center;cursor:pointer;' id="category_3" onclick='set_category(3);'>
						수술
					</div>	
					<div style='width:70px;height:30px;background:#ffffff;float:left;border:1px solid #e6e6e6;padding-top:5px;text-align:center;cursor:pointer;' id="category_4" onclick='set_category(4);'>
						물리치료
					</div>							

					<div style='width:590px;background:#e6e6e6;float:left;padding-top:20px;padding-left:40px;'>
						<input type='text' name='new_drug_name' style='width:440px;'><br>
		<div id="dsearch_auto_complete" style="display:none;"></div>
						<br>
						복용 1회 시 알약/주사 갯수/횟수 
						<select name='new_dosage_count'>
							<?
								for($i=1;$i<10;$i++)
								{
									?>
							<option value='<? echo $i;?>'><? echo $i;?></option>
							<?
								}
									?>
						</select> 회 <br/><br/>

						복용 시작일
						<input type="text" value="<? if ($row[1]=="") { echo date('Y-m-d'); } else echo $row[1];?>" name="new_start_date">
						<br/><br/>
						
						복용 빈도
						<select name='new_dosage_fq'>
							<?
								for($i=1;$i<=3;$i++)
								{
									?>
							<option value='1일 <? echo $i;?>회'>1일 <? echo $i;?>회</option>
							<?
								}
									?>
						</select>
						<br/><br/>

						복용 기간
						<select name='new_dosage_period'>
							<?
								for($i=1;$i<=10;$i++)
								{
									?>
							<option value='<? echo $i;?>'><? echo $i;?></option>
							<?
								}
									?>
						</select>
						<select name='new_dosage_period_type'>
							<option value='1'>일</option>
							<option value='2'>주</option>
							<option value='3'>월</option>
							<option value='4'>년</option>
						</select>
						<br/><br/>




				
					</div>
					<div style='width:590px;height:65px;background:#e6e6e6;float:left;padding-top:13px;padding-left:40px;'>

						<a  onclick="$('#frm_drug_add').submit();" style="cursor:pointer"><img src='./img/ndd_talk_save.png' border="0"></a>&nbsp;<a style='cursor:pointer;' onclick='history.back();'><img src='./img/ndd_talk_cancel.png' border="0"></a>
					</div>



					</form>
				</div>


				<div style="width:100%;height:15px;float:left;"><span></span></div>

				<div style="width:100%;height:1px;background:#CCCCCC;float:left;"><span></span></div>
				<div style="width:100%;height:2px;background:#ffffff;float:left;"><span></span></div>

				<div style="width:100%;height:15px;float:left;"><span></span></div>

				<!--  약물 리스트 시작 -->
				<div id="drug_list"></div>
				<!-- 약물 리스트 끝 -->
				

				<iframe name="iframe_temp" style='display:none;'></iframe>
		
		


				<div style="width:100%;height:15px;float:left;"><span></span></div>
				<br/>

				<div style="width:30px;height:30px;float:left;">2</div>
				<div style="width:600px;float:left;">
					어떤 검사를 받으셨습니까?<br/>
					<br/>
					<select id='new_test_type'>
						<option value="">검사종류</option>
						<?
							// 검사 목록 출력 시작

							$sql = "
								SELECT list_test_idx, name
								FROM ndd_list_test
							";
							$result = mysql_query($sql,$connect);
							while($row = mysql_fetch_row($result))
							{
						?>
						
						<option value="<?=$row[0];?>"><?=$row[1];?></option>

						<?
							}
							// 검사 목록 출력 끝
						?>

					</select>
					<br/>
					<br/>
					검사일 <input type="text" value="<?=date('Y-m-d')?>" id="new_test_date">
					<br/>
					<br/>
					검사에 대해 어떠한 설명을 들으셨습니까?<br/>
					<br/>
					<textarea id='new_test_desc' style='width:590px;height:115px;'></textarea><br>
					<input type='checkbox' id='new_test_no_desc' onclick="fn_disable_desc(this.checked);"> 듣지 못했습니다.

					<script>
					function fn_disable_desc(_disable)
					{
						if(_disable)
						{
							$('#new_test_desc').prop("disabled", true);
							$('#new_test_desc').hide();

						}
						else
						{
							$('#new_test_desc').prop("disabled", false);
							$('#new_test_desc').show();
						}
					}

					</script>
				
				</div>

				<div style="width:100%;height:15px;float:left;"><span></span></div>

				<!--div style="width:100%;height:15px;float:left;"><span></span></div>

				<div style="width:100%;height:1px;background:#CCCCCC;float:left;"><span></span></div>
				<div style="width:100%;height:2px;background:#ffffff;float:left;"><span></span></div>

				<div style="width:100%;height:15px;float:left;"><span></span></div-->


				
				
				
				<div style='width:100%;height:30px;padding-left:30px;float:left;'>
						<a  onclick="value_save();" style="cursor:pointer"><img src='./img/ndd_talk_save.png' border="0"></a>&nbsp;<a style='cursor:pointer;' onclick='history.back();'><img src='./img/ndd_talk_cancel.png' border="0"></a>
						
				</div>


				<div style="width:100%;height:15px;float:left;"><span></span></div>

				<div style="width:100%;height:1px;background:#CCCCCC;float:left;"><span></span></div>
				<div style="width:100%;height:2px;background:#ffffff;float:left;"><span></span></div>

				<div style="width:100%;height:15px;float:left;"><span></span></div>


				<div id="test_list"></div>
				
				
			
			</div>
			<? include "footer.php";?>		
		</div>

		
		<iframe src='' name='ifr_temp' style='display:none;'></iframe>
		<iframe name="ifr_temp_status" src="_blank" style="display:none;"></iframe>

		<script>
			load_test_list(0);

			function load_test_list(disease_idx)
			{

				$('#test_list').load('ndd_cure_test_list.php', { 'disease_idx':disease_idx });

			}	

			load_drug_list(0);

			function load_drug_list(disease_idx)
			{

				$('#drug_list').load('ndd_cure_drug_list.php', { 'disease_idx':disease_idx });

			}	


			function value_save()
			{
				if($('#new_test_type').val()=="")
				{
					alert("검사 종류에서 받으신 검사를 선택해 주세요.");
					return;
				}

				if($('#new_test_no_desc').attr('checked'))
					t_checked = "Y";
				else
					t_checked = "N";
					
				 $.post(
                    "ndd_cure_test_add.php", //서버측 스크립트 언어
                    {	't_type': $('#new_test_type').val(),
						't_date': $('#new_test_date').val(),
						't_desc': $('#new_test_desc').val(),
						't_no_desc': t_checked
					}, 
                    function (data) {         //콜백함수 : 결과값 받기 , data로 받아옴  
//                        $('#pnlDisplay').html(data);
						alert($('#new_test_date').val() + "에 받으신 " + $('#new_test_type option:selected').text() + " 이(가) 추가되었습니다.");
						$('#new_test_type').val('');
						$('#new_test_date').val("<?=date('Y-m-d')?>");
						$('#new_test_desc').val('');

						load_test_list(0);
                    }
                ); //end $.post()


			}
		</script>	
	</div>
 </body>
</html>
